package com.jaychen.tliaswebmanagement.mapper;

import com.github.pagehelper.Page;
import com.jaychen.tliaswebmanagement.pojo.StuQueryParam;
import com.jaychen.tliaswebmanagement.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Mapper
public interface StuMapper {
    Page<Student> page(StuQueryParam stuQueryParam);

    void deleteByIds(List<Integer> ids);


    void add(Student stu);

    @Select("select id, name, no, gender, phone, degree, id_card, is_college, address, graduation_date, violation_count," +
            " violation_score, clazz_id, create_time, update_time from student where id = #{id}")
    Student getById(Integer id);

    void update(Student stu);

    @Update("update student set " +
            "violation_score=violation_score+#{score}," +
            "violation_count=violation_count+1 " +
            "where id = #{id}")
    void violate(Integer id, Integer score);

    @MapKey("name")
    List<Map<String, Object>> countDegreeData();

    List<Map<String, Object>> getStudentCountData();
}
